<%--
  Created by IntelliJ IDEA.
  User: Gaara_XHG
  Date: 2020/10/8
  Time: 5:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:if test="${insertOwner==1}">
    <span>插入成功,插入车主id为：<span style="color: red">${ownerID}</span></span>
</c:if>
<c:if test="${remind==1}">
    <span style="color: red;font-weight: bold">该车主已经注册，不可重复操作！</span>
</c:if>
<div style="border:1px solid #999; padding: 10px">
    <form role="form" id="adOwn">
        <div class="col-md-4 form-group" style="color: grey;font-weight: normal">
            <label for="oname" class="control-label">车主姓名&nbsp;:&nbsp;</label><input type="text" name="oname"  id="oname" placeholder="请输入车主姓名">
        </div>
        <div class="col-md-4 form-group">
            <label for="ophone" class="control-label">车主电话&nbsp;:&nbsp;</label><input type="text"  name="ophone" id="ophone" placeholder="请输入车主电话">
        </div>
        <div class="col-md-4 form-group">
            <label for="oIdcard" class="control-label">车主身份证&nbsp;:&nbsp;</label><input type="text" name="oIdcard" id="oIdcard" placeholder="请输入车主身份证">
        </div>
        <br>
        <br>
        <div class="col-md-4 form-group">
            <label for="obank" class="control-label">车主银行卡号&nbsp;:&nbsp;</label><input type="text"  name="obank" id="obank" placeholder="请输入车主银行卡号">
        </div>
        <div class="col-md-4 form-group">
            <label for="ocreateDate" class="control-label">车主创建时间&nbsp;:&nbsp;</label><input type="text" name="ocreateDate" id="ocreateDate" placeholder="请输入车主创建时间">
        </div>
        <div class="col-md-4 form-group">
            <label for="cId" class="control-label">车辆id&nbsp;:&nbsp;</label><input type="text"  name="cId" id="cId" placeholder="请输入车辆id">
        </div>
        <br>
        <br>
        <div class="col-md-4 form-group">
            <label for="oprice" class="control-label">底价&nbsp;:&nbsp;</label><input type="text"  name="oprice" id="oprice" placeholder="请输入底价">
        </div>


        <button type="button" id="ADDOWNER" class="btn btn-default">提交</button>
        <c:if test="${insertOwner==1}">
            <span>插入成功,插入车主id为：<span style="color: red">${ownerID}</span></span>
        </c:if>
        <c:if test="${remind==1}">
            <span style="color: red;font-weight: bold">该车主已经注册，不可重复操作！</span>
        </c:if>
    </form>
</div>

<script>
    $(function () {
        $("#ADDOWNER").click(function () {
            // 取出所有数据
            let owner = $("#adOwn").serializeArray();
            let data = {};
            $.each(owner, function (index, item) {
                data[item.name] = item.value;
            });
            let json = JSON.stringify(data);
            console.log("json:",json);

            $.ajax({
                type:'post',
                contentType : "application/json;charset=utf-8",
                url:'${pageContext.request.contextPath}/admin/addOwner.action',
                data:JSON.stringify(data),
                success:function () {
                    $("#addOwner").load("/prj/jsp/adCenter/AddOwner.jsp");
                }
            });

        });
    })

</script>